#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
简单的测试脚本
"""
import requests
import json
import argparse

# 解析命令行参数
parser = argparse.ArgumentParser(description='停止分类服务')
parser.add_argument('port', type=int, nargs='?', default=8775, help='服务端口号，默认为8775')
args = parser.parse_args()

# 配置
API_URL = 'http://localhost:8051'
SERVICE_ID = '100000001'
PORT = args.port
MODEL_URL = 'http://localhost:8888/resnet50.zip'
PY_URL = 'http://localhost:8888/devdeploy.zip'

# 测试启动服务
# data = {
#     'serviceId': SERVICE_ID,
#     'serviceTag': 'start',
#     'modelUrl': MODEL_URL,
#     'pyUrl': PY_URL,
#     'port': PORT
# }
# response = requests.post(f'{API_URL}/start/', json=data)
# print('启动服务响应:', json.dumps(response.json(), indent=2, ensure_ascii=False))

# 测试停止服务cou
data = {
    'taskType': 'classification',
    'serviceId': SERVICE_ID,
    'serviceTag': 'stop',
    'port': PORT,
    'appType': 'cv'
}
response = requests.post(f'{API_URL}/stop/', json=data)
print('停止服务响应:', json.dumps(response.json(), indent=2, ensure_ascii=False))

# 测试删除服务
# data = {
#     'serviceId': SERVICE_ID,
#     'serviceTag': 'delete',
#     'port': PORT
# }
# response = requests.post(f'{API_URL}/delete/', json=data)
# print('删除服务响应:', json.dumps(response.json(), indent=2, ensure_ascii=False))
